#!/usr/bin/env python
#-*- encoding: utf-8 -*-

import wx
import codecs

class MainFrame(wx.Frame):
    def __init__(self):
      wx.Frame.__init__(self, None, -1, 'eve',   
                size=(300, 300)) 

      panel=wx.Panel(self,-1)
      wx.StaticText(panel,-1,"输入英文",(100,10))

      self.etxt=wx.TextCtrl(panel,-1,"",size=(300,100))
      self.etxt.SetInsertionPoint(0)

      wx.StaticText(panel,-1,"输入中文",(100,60))
      self.ctxt=wx.TextCtrl(panel,-1,"",size=(300,200))
    
      self.button=wx.Button(panel,-1,"增加",pos=(100,150))
      self.Bind(wx.EVT_BUTTON,self.onClick,self.button)
      self.button.Enable(False) 
         

      self.start=wx.Button(panel,-1,"开始",pos=(10,150))
      self.Bind(wx.EVT_BUTTON,self.startw,self.start)      

      self.end=wx.Button(panel,-1,"关闭",pos=(200,150))
      self.Bind(wx.EVT_BUTTON,self.endw,self.end)   
      self.end.Enable(False)
      self.Show()  

    def onClick(self,event):
      self.entxt=self.etxt.GetValue()
      self.zntxt=self.ctxt.GetValue()
      
      self.ff.writelines("msgid   "+'"'+self.entxt+'"\n')
      self.ff.writelines("msgstr  "+'"'+self.zntxt+'"\n')
      self.ff.writelines("\n")
      
      self.etxt.SetValue("")
      self.ctxt.SetValue("")
    def startw(self,event):
      self.ff=codecs.open("pyfa.po","a",'utf-8')
      self.button.Enable(True)
      self.start.Enable(False)
      self.end.Enable(True)
      
    def endw(self,event):
      self.ff.close()
      wx.Exit()
        

def main():
   app=   wx.App(False)
   MainFrame()
   app.MainLoop()
 
if __name__=="__main__":
     main()


